perm filename A37.TEX[106,PHY] blob
sn#807736 filedate 1985-11-15 generic text, type C, neo UTF8
COMMENT ā VALID 00004 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 %tables are on next pages for separate running
C00012 00003 %figure 1 for a37.tex[106,phy] see a37a.tex
C00016 00004 %figure 2 for a37.tex[106,phy] see a37b.tex
C00021 ENDMK
Cā;
%tables are on next pages for separate running
\magnification\magstephalf
\input macro.tex
\def\today{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space\number\day, \number\year}
\baselineskip 14pt
\rm
\line{\sevenrm a37.tex[106,phy] \today\hfill}
\bigskip
\line{{\bf Final Project\hfill}}
\bigskip
The game of Battleship is played on a $9\times 9$ square `ocean', like
this:
\figbox 2.5in:
\noindent
on which are placed four submarines, three destroyers, two cruisers, and
one battleship, of lengths one, two, three and four, respectively.
Ships may not touch. Each player lays out his fleet on his own ocean,
keeping it concealed. Then the players take turns firing salvos of three
shells, announcing the coordinates of the squares fired on,
say E4, C7,~C9. The opponent reports only the total damage done, ``two
cruisers'' in the example.
The winner is the first to sink all the opponent's ships by hitting each
square they occupy.
Write a program which plays one or both sides of the game. To play the
defensive side, it should place its ships randomly and/or cleverly, read incoming
salvos, and report damage. On request, it should show a picture of its fleet.
Be careful to avoid situations like this one:
\figbox 2.5in:
\noindent where there is no place for the battleship. When I~play, I~often
pack my major ships into corners and ``hide'' the smaller ones in the
remaining expanse of open ocean.
To play the offensive side well is a major challenge. Don't commit yourself
to it unless you think you can succeed. {\sl Bon Voyage\/}.
\bigskip
\parindent0pt
\copyright 1984 Robert W. Floyd
First draft September 24, 1984
\bye
%figure 1 for a37.tex[106,phy] see a37a.tex
$$\vbox{\tabskip0pt\offinterlineskip
\halign{#\hfill\quad\strut&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#\cr
\omit&\multispan{19}\hrulefill\cr
\omit&height2pt&&\omit&&&&&&\omit&&\omit&&&&&&\omit&&\cr
A&&&\omit&&&S&&&\omit&&\omit&&&C&&&\omit&&\cr
\omit&&&\omit&&\multispan3\hrulefill&&\omit&&\omit&&&&&&\omit&&\cr
\omit&height2pt&&\omit&&\omit&&\omit&&\omit&&\omit&&&&&&\omit&&\cr
B&&&\multispan9&&&C&&&\omit&&\cr
\omit&\multispan9\hrulefill&&\omit&&&&&&\multispan3\hrulefill\cr
\omit&height2pt&&\multispan5&&&&\omit&&&&&&&&\cr
C&&B&\omit&B&\omit&B&\omit&B&&&\omit&&&C&&&&C&\cr
\omit&\multispan9\hrulefill&&\omit&&\multispan3\hrulefill&&&&\cr
\omit&height2pt&&\multispan{13}&&&&\cr
D&&&\multispan{13}&&&C&\cr
\omit&&&\multispan5\hrulefill&&\omit&&\multispan3\hrulefill&&\omit&&\cr
\omit&height2pt&&&&\omit&&&&\omit&&&&&&\omit&&&&\cr
E&&&&D&\omit&D&&&\omit&&&S&&&\omit&&&C&\cr
\omit&&&\multispan5\hrulefill&&\omit&&\multispan3\hrulefill&&\omit&&\multispan3%
\hrulefill\cr
\omit&height2pt&&\multispan{15}&&\cr
F&&&\multispan{15}&&\cr
\omit&&&\omit&&\multispan3\hrulefill&&\omit&&\omit&&\multispan3\hrulefill&&\omit&&\cr
\omit&height2pt&&\omit&&&&&&\omit&&\omit&&&&&&\omit&&\cr
G&&&\omit&&&S&&&\omit&&\omit&&&S&&&\omit&&\cr
\omit&\multispan3\hrulefill&&\multispan3\hrulefill&&\omit&&\omit&&\multispan3%
\hrulefill&&\omit&&\cr
\omit&height2pt&&&&\multispan{13}&&\cr
H&&D&&&\multispan{13}&&\cr
\omit&&&&&\omit&&\omit&&\omit&&\omit&&\multispan5\hrulefill&&\cr
\omit&height2pt&&&&\multispan7&&&&\omit&&&&\cr
I&&D&&&\multispan7&&&D&\omit&D&&&\cr
\omit&\multispan{19}\hrulefill\cr
\noalign{\smallskip}
&\omit&1&\omit&2&\omit&3&\omit&4&\omit&5&\omit&6&\omit&7&\omit&8&\omit&9&\omit\cr
}}$$
%figure 2 for a37.tex[106,phy] see a37b.tex
$$\vbox{\tabskip0pt\offinterlineskip
\halign{#\hfill\quad\strut&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#&$\;$\hfil #\hfil$\;$%
&\vrule#\cr
\omit&\multispan{19}\hrulefill\cr
\omit&height2pt&\multispan{17}&\cr
A&&\multispan{17}&\cr
\omit&&&\multispan3\hrulefill&&\omit&&\multispan3\hrulefill&\multispan7&\cr
%&height2pt&&&&&&\omit&&&&&&\multispan6&\cr
B&&&&&&&\omit&&&&&&\multispan6&\cr
\omit&&&\multispan3\hrulefill&&\omit&&\multispan3\hrulefill%
&&\omit&&\omit&&\omit&&\cr
\omit&height2pt&\multispan{17}&\cr
C&&&\multispan{16}&\cr
\omit&&&\multispan6&\multispan3\hrulefill&&\omit%
&&\multispan3\hrulefill&&\cr
\omit&height2pt&\multispan6&&&&&&\omit&&&&&&\cr
D&&\multispan{12}&&&&&&\cr
\omit&&\multispan{12}&&\multispan3\hrulefill&&\cr
\omit&height2pt&\multispan{17}&\cr
E&&&\multispan5&&&&&&\omit&&&&&&\cr
\omit&&&\multispan6&\multispan3\hrulefill&&\omit&&&&&&\cr
\omit&height2pt&\multispan{12}&&&&&&\cr
F&&\multispan{17}&\cr
\omit&&&\multispan3\hrulefill&&\omit&&\omit&&\multispan3\hrulefill%
&&\omit&&\omit&&\cr
\omit&height2pt&&&&&&\omit&&\omit&&&&&&\omit&&\omit&&\cr
G&&&&&&&\omit&&\omit&&&&&&\omit&&\omit&&\cr
\omit&&&\multispan3\hrulefill&&\omit&&\omit&&&&\omit&&\omit&&\omit&&\cr
\omit&height2pt&\multispan8&&&&&&\omit&&\omit&&\cr
H&&\multispan8&&&&&&\omit&&\omit&&\cr
\omit&height2pt&\multispan8&&&&&&\omit&&\omit&&\cr
I&&\multispan8&&&&&&\omit&&\omit&&\cr
\omit&\multispan{19}\hrulefill\cr
\noalign{\smallskip}
&\omit&1&\omit&2&\omit&3&\omit&4&\omit&5&\omit&6&\omit&7&\omit&8&\omit&9&\omit\cr
}}$$